
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>数据交换中心修改</title>
<%@ include file="/commons/css_js_head.jsp"%>
<script type="text/javascript" src="${ctx }/js/cascadeConnectionMenu.js"></script>
<script type="text/javascript" src="${ctx }/js/xindiqu.js"></script>
<script type="text/javascript">
	
	window.onload=function(){//页面加载完毕后执行此方法
	//初始化各级联菜单，setDefaultAreaCode方法通过地区码参数指定默认显示的地区
	
	var dq = document.getElementById("mom_dqM").value;
	new CascadeConnectionMenu().setDefaultAreaCode(dq).//默认显示"越秀区",
											initByArray('mom.selA',//内容为省的select元素的name（字符串）或id值
											shengArray,//内容为所有省的数组对象
											'mom.selB',//内容为市的select元素的name（字符串）或id值
											shiArray,//内容为所有市的数组对象
											'mom.selC',//内容为区的select元素的name（字符串）或id值
											quArray);//内容为所有区的数组对象
	}
		
</script>
<script type="text/javascript">
//复写Url
doUpdateUrl = "${ctx }/base/tsMomAction!doUpdate.ts";
doReturnUrl = "${ctx }/base/tsMomAction!doList.ts";



//校验输入框
function checkUserName() {

	
	var name = document.getElementById("mom_name").value;
	var nameValue = document.getElementById("nameValue")
	var port =  document.getElementById("mom.port").value;
	
	

	var thename = name.replace(/(^\s*)|(\s*$)/g, "");
	
	if(thename == "")
	{
	    var innerHtml = "<span class='ts_red'> 名称不能为空！<\/span>";
		cleanData(name,nameValue,innerHtml);
		return false;
	}
	else
	{
	    var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(nameValue,innerHtml);
		return true;
	}

}

function checkForm(){
	
	if(
		checkUserName() 
		){
		return true;
	}else{
		return false;
	}
}
//保存
function doUpdate() {
	
	var _form = document.forms[0];
	if (doUpdateUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}

    if(checkForm()){
    
		_form.action = doUpdateUrl;
		_form.submit();
		onCancel();
		parent.window.location.reload();
	}
	
}
  
 //关闭小窗口
function onCancel()
{
	closeWindow();
}
function closeWindow()
{
	self.parent.tb_remove();
}
 //验证端口
function checkPort() {

	var port = document.getElementById("mom_port");
	var portValue = document.getElementById("portValue");
	var reg = /^[1-9][0-9]{0,9}$/;
	
	if(port.value.replace(/(^\s*)|(\s*$)/g,"")==""){
		var innerHtml = "<span class='ts_red'>请输入端口！<\/span>";
		cleanData(port,portValue,innerHtml);
		return false;
	}else if(!port.value.match(reg)){
		var innerHtml = "<span class='ts_red'>请输正确的端口！<\/span>";
		
		cleanData(port,portValue,innerHtml);
		return false;
	}else{
		//var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		//disInfo(portValue,innerHtml);
		checkCompCodeAndDeviceCode();
		return true;
	}
	
	
}

//验证IP地址
function checkIpAddress() {

	var ipAddress = document.getElementById("mom.ipAddress");
	var ipAddressInfo = document.getElementById("ipAddressInfo");
	var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/; //验证Ip的正则表达式

	if(ipAddress.value.replace(/(^\s*)|(\s*$)/g,"")==""){
		var innerHtml = "<span class='ts_red'>请输入IP地址！<\/span>";
		disInfo(ipAddressInfo,innerHtml);
		return false;
	}else if(!ipAddress.value.match(reg)){
		var innerHtml = "<span class='ts_red'>输入的IP地址不正确！<\/span>";
		
		disInfo(ipAddressInfo,innerHtml);
		return false;
	}else{
		//var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(ipAddressInfo,"");
		checkCompCodeAndDeviceCode1();
		return true;
	}
	
}

var xmlHttpRequest = null;
  
  //校验厂家编码与机器码的唯一性
  function checkCompCodeAndDeviceCode()
  {
     //IE浏览器用ActioveXObject创建对象
     if(window.ActiveXObject)
     {
        xmlHttpRequest = new  ActiveXObject("Microsoft.XMLHttp");
     }
     //非IE浏览器 用XMLHttpRequest创建对象
     else if(window.XMLHttpRequest)
     {
     
        xmlHttpRequest = new XMLHttpRequest();
     }
     if(xmlHttpRequest)
     {
       //关联好回调函数
       var compCode = document.getElementById("mom.port").value;
       var deviceCode = document.getElementById("mom.ipAddress").value;
       var url = "base/tsMomAction!findCompCodeAndDeviceCode.ts?compCode="+compCode+"&deviceCode="+deviceCode;
       xmlHttpRequest.open("GET",url,true);
       xmlHttpRequest.onreadystatechange = callAjaxBack;//指定回调函数
       xmlHttpRequest.send(null);
      }
     
     function callAjaxBack()
     {
     
       if(xmlHttpRequest.readystate == 4)
       {
         if(xmlHttpRequest.status == 200)
         {
            var inner =  xmlHttpRequest.responseText;
            var port = document.getElementById("mom.port");
            var portValue = document.getElementById("portValue");
            if(inner.length != 0)
            {
              var innerHtml = "<span class='ts_red'>"+inner+"<\/span>";
              //alert(inner);
              disInfo(portValue,innerHtml);
              $("#confirmBtn").attr('disabled', true);
            }
            else
            {
                var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
				disInfo(portValue,innerHtml);
				
				$("#confirmBtn").attr('disabled', false);
            }
         }
       }
    }
 }
 
  function checkCompCodeAndDeviceCode1()
  {
     //IE浏览器用ActioveXObject创建对象
     if(window.ActiveXObject)
     {
        xmlHttpRequest = new  ActiveXObject("Microsoft.XMLHttp");
     }
     //非IE浏览器 用XMLHttpRequest创建对象
     else if(window.XMLHttpRequest)
     {
     
        xmlHttpRequest = new XMLHttpRequest();
     }
     if(xmlHttpRequest)
     {
       //关联好回调函数
       var compCode = document.getElementById("mom.port").value;
       var deviceCode = document.getElementById("mom.ipAddress").value;
       var url = "base/tsMomAction!findCompCodeAndDeviceCode.ts?compCode="+compCode+"&deviceCode="+deviceCode;
       xmlHttpRequest.open("GET",url,true);
       xmlHttpRequest.onreadystatechange = callAjaxBack1;//指定回调函数
       xmlHttpRequest.send(null);
      }
     
     function callAjaxBack1()
     {
     
       if(xmlHttpRequest.readystate == 4)
       {
         if(xmlHttpRequest.status == 200)
         {
            var inner =  xmlHttpRequest.responseText;
            var port = document.getElementById("mom.port");
            var portValue = document.getElementById("portValue");
            if(inner.length != 0)
            {
              var innerHtml = "<span class='ts_red'>"+inner+"<\/span>";
              //alert(inner);
              disInfo(portValue,innerHtml);
              $("#confirmBtn").attr('disabled', true);
            }
            else
            {
                    var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
					disInfo(ipAddressInfo,innerHtml);
				
				$("#confirmBtn").attr('disabled', false);
            }
         }
       }
    }
 }
</script>
	</head>

	<body style="overflow-x: hidden">
		<div class="mTitle">
			<span class="hidsearch"></span>
			<b class="bbig">数据交换中心信息修改</b> 带
			<b class="fred"> * </b>号为必填项
		</div>

		<form action="/base/tsMomAction" method="post">
			<s:hidden name="mom.momid"></s:hidden>
			<s:hidden name="mom.type" value="1"></s:hidden>
			<s:hidden name="mom.dqM"></s:hidden>
			<!--list -->
			<div class="mainAdd">
				<table class="addTable">

					

					<tr>
						<td colspan="4">
							<b class="fblue">数据交换中心基本信息</b>
						</td>
					</tr>
					
					
					
					<tr>
						<th>
							<b class="fred"> * </b> 数据交换中心名称：
						</th>
						<td>
							<s:textfield name="mom.name" maxlength="20" theme="simple"></s:textfield>
							<span id="nameValue"></span>
						</td>
						
					  <th>
							<b class="fred"> * </b> 是否上线：
						</th>
						<td>
						
						    <s:select list="#{1:'是',0:'否'}"  
							theme="simple"
							name="mom.status"
							listKey="key" 
							cssStyle="width:50px;"	
							listValue="value"  
							headerKey="0" 
							/> 
						<span id="statusInfo"></span>
						</td>
					</tr>
					
					<tr>
						<th>
							<b class="fred"> * </b> IP地址：
						</th>
						<td>
							<s:textfield name="mom.ipAddress"  onkeyup="checkIpAddress();" maxlength="20" theme="simple" ></s:textfield>
							<span id="ipAddressInfo"></span>
						</td>
						 <th>
							<b class="fred"> *  </b> 端口：
						</th>
						<td>
							<s:textfield name="mom.port" maxlength="5" onkeyup="checkPort()" theme="simple"></s:textfield>
							<span id="portValue"></span>
						</td>
						 
										
					</tr>
					<tr>
						<th>
							DNS域名：
						</th>
						<td colspan="3">
							<s:textfield name="mom.dns" maxlength="30" theme="simple" cssStyle="width:260px;"></s:textfield>
						</td>
						
					</tr>
					<tr>
						<th width="10%">
							<b class="fred">*</b>区域：
						</th>
						<td width="40%" colspan="3">
						省：<select name="mom.selA" style="width:140" value="" id="mom_selA"></select>
 			 			 市：<select name="mom.selB" style="width:140" value="" id="mom.selB"></select>
  			  			区：<select name="mom.selC" style="width:140" value="" id="mom.selC"></select>
						</td>
					</tr>
					<tr>
						<th>
							<b class="fred"> </b> 地址：
						</th>
						<td  colspan="3">
							<s:textfield name="mom.address" maxlength="500" cssStyle="width:600px;"	 theme="simple"></s:textfield>
						</td>
					</tr>
					<tr>	
						<th>
							 备注：
						</th>
						<td  colspan="3">
							<s:textfield name="mom.remark"  maxlength="500" cssStyle="width:600px;"	  theme="simple"></s:textfield>
						</td>
					</tr>
				</table>
			</div>
			<!--end list -->
			<div class="addToolbar">
				<p>
					<input class="btn" name="btn_confirm" value="确定" type="button"
						onclick="doUpdate();" id="confirmBtn"/>
					<input class="btn" name="btn_return" value="返回" type="button"
						onclick="onCancel();"  />
				</p>
			</div>

		</form>

	</body>

<script type="text/javascript">
document.onkeydown = function(e) {
	if (!e)
		e = window.event;//火狐中是 window.event
	if ((e.keyCode || e.which) == 13) {
		doUpdate();
	}
}
</script>
</html>
